<?php


abstract class BaseCompanyPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'tech_company';

	
	const CLASS_DEFAULT = 'lib.model.Company';

	
	const NUM_COLUMNS = 23;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'tech_company.ID';

	
	const NAME = 'tech_company.NAME';

	
	const NAMEHEBREW = 'tech_company.NAMEHEBREW';

	
	const DESCRIPTION = 'tech_company.DESCRIPTION';

	
	const AUTHOR_ID = 'tech_company.AUTHOR_ID';

	
	const FOUNDED = 'tech_company.FOUNDED';

	
	const EMAIL = 'tech_company.EMAIL';

	
	const LOCATION = 'tech_company.LOCATION';

	
	const URL = 'tech_company.URL';

	
	const SLUG = 'tech_company.SLUG';

	
	const BLOGURL = 'tech_company.BLOGURL';

	
	const RSSURL = 'tech_company.RSSURL';

	
	const TWITTERUSER = 'tech_company.TWITTERUSER';

	
	const PHONENUMBER = 'tech_company.PHONENUMBER';

	
	const EMAILCONTACT = 'tech_company.EMAILCONTACT';

	
	const ROUNDS = 'tech_company.ROUNDS';

	
	const FOUNDERS = 'tech_company.FOUNDERS';

	
	const NUMBEREMPLOY = 'tech_company.NUMBEREMPLOY';

	
	const LOGOURL = 'tech_company.LOGOURL';

	
	const PUBLISHSTATE = 'tech_company.PUBLISHSTATE';

	
	const VERSIONSHADOW = 'tech_company.VERSIONSHADOW';

	
	const CREATED_AT = 'tech_company.CREATED_AT';

	
	const UPDATED_AT = 'tech_company.UPDATED_AT';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Namehebrew', 'Description', 'AuthorId', 'Founded', 'Email', 'Location', 'Url', 'Slug', 'Blogurl', 'Rssurl', 'Twitteruser', 'Phonenumber', 'Emailcontact', 'Rounds', 'Founders', 'Numberemploy', 'Logourl', 'Publishstate', 'Versionshadow', 'CreatedAt', 'UpdatedAt', ),
		BasePeer::TYPE_COLNAME => array (CompanyPeer::ID, CompanyPeer::NAME, CompanyPeer::NAMEHEBREW, CompanyPeer::DESCRIPTION, CompanyPeer::AUTHOR_ID, CompanyPeer::FOUNDED, CompanyPeer::EMAIL, CompanyPeer::LOCATION, CompanyPeer::URL, CompanyPeer::SLUG, CompanyPeer::BLOGURL, CompanyPeer::RSSURL, CompanyPeer::TWITTERUSER, CompanyPeer::PHONENUMBER, CompanyPeer::EMAILCONTACT, CompanyPeer::ROUNDS, CompanyPeer::FOUNDERS, CompanyPeer::NUMBEREMPLOY, CompanyPeer::LOGOURL, CompanyPeer::PUBLISHSTATE, CompanyPeer::VERSIONSHADOW, CompanyPeer::CREATED_AT, CompanyPeer::UPDATED_AT, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'namehebrew', 'description', 'author_id', 'founded', 'email', 'location', 'url', 'slug', 'blogurl', 'rssurl', 'twitteruser', 'phonenumber', 'emailcontact', 'rounds', 'founders', 'numberemploy', 'logourl', 'publishstate', 'versionshadow', 'created_at', 'updated_at', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Namehebrew' => 2, 'Description' => 3, 'AuthorId' => 4, 'Founded' => 5, 'Email' => 6, 'Location' => 7, 'Url' => 8, 'Slug' => 9, 'Blogurl' => 10, 'Rssurl' => 11, 'Twitteruser' => 12, 'Phonenumber' => 13, 'Emailcontact' => 14, 'Rounds' => 15, 'Founders' => 16, 'Numberemploy' => 17, 'Logourl' => 18, 'Publishstate' => 19, 'Versionshadow' => 20, 'CreatedAt' => 21, 'UpdatedAt' => 22, ),
		BasePeer::TYPE_COLNAME => array (CompanyPeer::ID => 0, CompanyPeer::NAME => 1, CompanyPeer::NAMEHEBREW => 2, CompanyPeer::DESCRIPTION => 3, CompanyPeer::AUTHOR_ID => 4, CompanyPeer::FOUNDED => 5, CompanyPeer::EMAIL => 6, CompanyPeer::LOCATION => 7, CompanyPeer::URL => 8, CompanyPeer::SLUG => 9, CompanyPeer::BLOGURL => 10, CompanyPeer::RSSURL => 11, CompanyPeer::TWITTERUSER => 12, CompanyPeer::PHONENUMBER => 13, CompanyPeer::EMAILCONTACT => 14, CompanyPeer::ROUNDS => 15, CompanyPeer::FOUNDERS => 16, CompanyPeer::NUMBEREMPLOY => 17, CompanyPeer::LOGOURL => 18, CompanyPeer::PUBLISHSTATE => 19, CompanyPeer::VERSIONSHADOW => 20, CompanyPeer::CREATED_AT => 21, CompanyPeer::UPDATED_AT => 22, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'namehebrew' => 2, 'description' => 3, 'author_id' => 4, 'founded' => 5, 'email' => 6, 'location' => 7, 'url' => 8, 'slug' => 9, 'blogurl' => 10, 'rssurl' => 11, 'twitteruser' => 12, 'phonenumber' => 13, 'emailcontact' => 14, 'rounds' => 15, 'founders' => 16, 'numberemploy' => 17, 'logourl' => 18, 'publishstate' => 19, 'versionshadow' => 20, 'created_at' => 21, 'updated_at' => 22, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/CompanyMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.CompanyMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = CompanyPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(CompanyPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(CompanyPeer::ID);

		$criteria->addSelectColumn(CompanyPeer::NAME);

		$criteria->addSelectColumn(CompanyPeer::NAMEHEBREW);

		$criteria->addSelectColumn(CompanyPeer::DESCRIPTION);

		$criteria->addSelectColumn(CompanyPeer::AUTHOR_ID);

		$criteria->addSelectColumn(CompanyPeer::FOUNDED);

		$criteria->addSelectColumn(CompanyPeer::EMAIL);

		$criteria->addSelectColumn(CompanyPeer::LOCATION);

		$criteria->addSelectColumn(CompanyPeer::URL);

		$criteria->addSelectColumn(CompanyPeer::SLUG);

		$criteria->addSelectColumn(CompanyPeer::BLOGURL);

		$criteria->addSelectColumn(CompanyPeer::RSSURL);

		$criteria->addSelectColumn(CompanyPeer::TWITTERUSER);

		$criteria->addSelectColumn(CompanyPeer::PHONENUMBER);

		$criteria->addSelectColumn(CompanyPeer::EMAILCONTACT);

		$criteria->addSelectColumn(CompanyPeer::ROUNDS);

		$criteria->addSelectColumn(CompanyPeer::FOUNDERS);

		$criteria->addSelectColumn(CompanyPeer::NUMBEREMPLOY);

		$criteria->addSelectColumn(CompanyPeer::LOGOURL);

		$criteria->addSelectColumn(CompanyPeer::PUBLISHSTATE);

		$criteria->addSelectColumn(CompanyPeer::VERSIONSHADOW);

		$criteria->addSelectColumn(CompanyPeer::CREATED_AT);

		$criteria->addSelectColumn(CompanyPeer::UPDATED_AT);

	}

	const COUNT = 'COUNT(tech_company.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT tech_company.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(CompanyPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(CompanyPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = CompanyPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = CompanyPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return CompanyPeer::populateObjects(CompanyPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			CompanyPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = CompanyPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}

	
	public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(CompanyPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(CompanyPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(CompanyPeer::AUTHOR_ID, UserPeer::ID);

		$rs = CompanyPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinCompanyShadow(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(CompanyPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(CompanyPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(CompanyPeer::VERSIONSHADOW, CompanyShadowPeer::ID);

		$rs = CompanyPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinUser(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		CompanyPeer::addSelectColumns($c);
		$startcol = (CompanyPeer::NUM_COLUMNS - CompanyPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		UserPeer::addSelectColumns($c);

		$c->addJoin(CompanyPeer::AUTHOR_ID, UserPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = CompanyPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = UserPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getUser(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addCompany($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initCompanys();
				$obj2->addCompany($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinCompanyShadow(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		CompanyPeer::addSelectColumns($c);
		$startcol = (CompanyPeer::NUM_COLUMNS - CompanyPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		CompanyShadowPeer::addSelectColumns($c);

		$c->addJoin(CompanyPeer::VERSIONSHADOW, CompanyShadowPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = CompanyPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = CompanyShadowPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getCompanyShadow(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addCompany($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initCompanys();
				$obj2->addCompany($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
	{
		$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(CompanyPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(CompanyPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(CompanyPeer::AUTHOR_ID, UserPeer::ID);

		$criteria->addJoin(CompanyPeer::VERSIONSHADOW, CompanyShadowPeer::ID);

		$rs = CompanyPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinAll(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		CompanyPeer::addSelectColumns($c);
		$startcol2 = (CompanyPeer::NUM_COLUMNS - CompanyPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		UserPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;

		CompanyShadowPeer::addSelectColumns($c);
		$startcol4 = $startcol3 + CompanyShadowPeer::NUM_COLUMNS;

		$c->addJoin(CompanyPeer::AUTHOR_ID, UserPeer::ID);

		$c->addJoin(CompanyPeer::VERSIONSHADOW, CompanyShadowPeer::ID);

		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = CompanyPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);


					
			$omClass = UserPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getUser(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addCompany($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj2->initCompanys();
				$obj2->addCompany($obj1);
			}


					
			$omClass = CompanyShadowPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3 = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getCompanyShadow(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addCompany($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj3->initCompanys();
				$obj3->addCompany($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(CompanyPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(CompanyPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(CompanyPeer::VERSIONSHADOW, CompanyShadowPeer::ID);

		$rs = CompanyPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptCompanyShadow(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(CompanyPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(CompanyPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(CompanyPeer::AUTHOR_ID, UserPeer::ID);

		$rs = CompanyPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinAllExceptUser(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		CompanyPeer::addSelectColumns($c);
		$startcol2 = (CompanyPeer::NUM_COLUMNS - CompanyPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		CompanyShadowPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + CompanyShadowPeer::NUM_COLUMNS;

		$c->addJoin(CompanyPeer::VERSIONSHADOW, CompanyShadowPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = CompanyPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = CompanyShadowPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getCompanyShadow(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addCompany($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initCompanys();
				$obj2->addCompany($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptCompanyShadow(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		CompanyPeer::addSelectColumns($c);
		$startcol2 = (CompanyPeer::NUM_COLUMNS - CompanyPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		UserPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;

		$c->addJoin(CompanyPeer::AUTHOR_ID, UserPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = CompanyPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = UserPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getUser(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addCompany($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initCompanys();
				$obj2->addCompany($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}

	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return CompanyPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(CompanyPeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(CompanyPeer::ID);
			$selectCriteria->add(CompanyPeer::ID, $criteria->remove(CompanyPeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(CompanyPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(CompanyPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof Company) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(CompanyPeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(Company $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(CompanyPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(CompanyPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(CompanyPeer::DATABASE_NAME, CompanyPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = CompanyPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(CompanyPeer::DATABASE_NAME);

		$criteria->add(CompanyPeer::ID, $pk);


		$v = CompanyPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(CompanyPeer::ID, $pks, Criteria::IN);
			$objs = CompanyPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseCompanyPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/CompanyMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.CompanyMapBuilder');
}
